// component/loading/index.js
import boolean from "../../miniprogram_npm/lin-ui/common/async-validator/validator/boolean";

Component({
  /**
   * 组件的属性列表
   */
  properties: {

    show:{
      type: Boolean,
      value: false
    },
    type:{
      type: String,
      value: "spring"
    },
    fullScreen: Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {

  },
  attached() {
    this._init();
  },

  pageLifetimes: {
    show() {
      this._init();
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {

    _init() {
      wx.xp = wx.xp || {}

      wx.xp.showLoading = (options) => {
        const {
          fullScreen = true,
          type = 'spring',
        } = { ...options }

        this.setData({
          fullScreen,
          type,
          show: true
        });
      }

      wx.xp.hideLoading = () => {
        this.setData({
          show: false
        })
      }
    },


  }
})
